#include <iostream>
#include <vector>
#include <string>
#include <fstream>

using namespace std;

void prefix_function(string& s, vector<int>& p)
{
    p.clear();
    p.resize(s.length());
    for (int i = 1; i < s.size(); ++i)
    {
        if (s[i] == s[p[i - 1]])
        {
            p[i] = p[i - 1] + 1;
        } else
        {
            int j = p[i - 1];
            while (j > 0 && s[i] != s[j])
            {
                j = p[j - 1];
            }
            p[i] = j;
        }
    }
}

int main()
{
    freopen("input.txt", "r", stdin);
    string s;
    string s1;
    getline(cin, s);
    getline(cin, s1);
    vector<int> p;
    prefix_function(s1, p);
    vector<int> a(s.length());
    if (s[0] == s1[0]) a[0] = 1;
    for (int i = 1; i < s.length(); ++i)
    {
        int j = a[i - 1];
        while (j > 0 && s[i] != s1[j])
        {
            j = p[j - 1];
        }
        if (s[i] == s1[j]) a[i] = min(j + 1, (int)s1.length());
    }
    for (int i = 0; i < a.size(); ++i)
    {
        if (a[i] == s1.length())
        {
            cout<<i - s1.length() + 1<<endl;
            return 0;
        }
    }
    return 0;
}
